// 计算从 0 开始，例如 m = 3, n = 2，我们只要向下 1 步，向右 2 步就一定能达到终点
// 动态规划
var uniquePaths = function (m, n) {
  var dp = new Array(m);
  for (let i = 0; i < m; i++) {
    dp[i] = new Array(n);
    dp[i][0] = 1;
  }
  for (let j = 0; j < n; j++) {
    dp[0][j] = 1;
  }
  for (let k = 1; k < m; k++) {
    for (let r = 1; r < n; r++) {
      dp[k][r] = dp[k - 1][r] + dp[k][r - 1];
    }
  }
  return dp[m - 1][n - 1];
}